<template>
	<view style="height: 32rpx;"></view>
	<view class="num">
		<view>{{userinfo.consumer_coupon}}</view>
		<view>积分总额</view>
	</view>

	<view class="info">
		<view class="tit">钱包明细</view>

		<view class="info-item"
			v-for="(item,index) in list">
			<view>
				<view>{{item.title}}</view>
				<view>{{timeFormat(item.created_at, 'yyyy-mm-dd hh:MM:ss')}}</view>
			</view>
			<view class="red">{{item.nums.slice(0,1)== '-'? item.nums: `+${item.nums}`}}</view>
		</view>

		<view class="tips">
			全部明细已获取~~
		</view>
	</view>
</template>

<script setup>
	import { timeFormat } from '@/uni_modules/uview-plus';
	import { onLoad } from '@dcloudio/uni-app'
	import api from '../../api/api';
	import { useCounterStore } from '/stores/user';
	import { storeToRefs } from 'pinia'
	import { reactive, ref } from 'vue';
	const use = useCounterStore()
	const { userinfo } = storeToRefs(use)

	onLoad(() => {
		consumer_coupon_bills()
	})

	const list = reactive([])

	function consumer_coupon_bills() {
		api.user.consumer_coupon_bills().then(res => {
			Object.assign(list, res.data.list_data)
		})
	}
</script>

<style lang="scss">
	.num {
		width: 686rpx;
		height: 240rpx;
		background-image: linear-gradient(90deg, #FF9E4C 0%, #FF7316 100%);
		border-radius: 12rpx;
		margin: 0 auto;
		display: flex;
		align-items: center;
		flex-direction: column;
		justify-content: center;
		font-weight: 600;
		font-size: 44rpx;
		color: #FFFFFF;

		>view:nth-child(2) {
			font-weight: 400;
			font-size: 28rpx;
			color: #FFFFFF;
			margin-top: 20rpx;
		}
	}

	.info {
		padding: 32rpx;

		.tit {
			font-weight: 600;
			font-size: 32rpx;
			color: #333333;
			margin-bottom: 30rpx;
		}

		.info-item {
			height: 150rpx;
			border-bottom: 2rpx solid #d9d9d9;
			display: flex;
			justify-content: space-between;
			align-items: center;

			>view:nth-child(1) {
				font-weight: 500;
				font-size: 28rpx;
				color: #333333;

				>view:nth-child(2) {
					font-weight: 400;
					font-size: 24rpx;
					color: #9A9A9A;
					margin-top: 24rpx;
				}
			}

			.red {
				font-weight: 600;
				font-size: 28rpx;
				color: #FF345E;
			}

			.green {
				font-weight: 600;
				font-size: 28rpx;
				color: #489C6F;
			}
		}

		.tips {
			text-align: center;
			width: 100%;
			font-size: 26rpx;
			color: #c1c1c1;
			margin-top: 32rpx;
		}
	}
</style>